﻿using System;
using Me.Amon.Da.Db;
using Com.Winshine.WMS.Util;

namespace Com.Winshine.WMS.Flow.SI.Receiving
{
    public class DReceiving : IReceiving
    {
        public void Notice(string orderCode)
        {
            LogsUtil.Info("核收", "Notice:" + orderCode);

            SavePUT(orderCode);

            IFlow.NextSiNode(IFlow.FLOW_SI_DOCKING).Notice(orderCode);
        }

        public string GenPUTCode(string order)
        {
            return "PUT" + DateTime.UtcNow.ToString("yyyyMMddHHmmsszzzzzz");
        }

        public void SavePUT(string order)
        {
            var now = DateTime.Now;

            var dba = new RDBEngine();
            dba.AddTable("si_putaway");
            dba.AddParam("id", now.ToString("yyyyMMddHHmmss"));
            dba.AddParam("code", GenPUTCode(order));
            dba.AddParam("asnid", order);
            dba.ExecuteInsert();
        }
    }
}